﻿@{
	ViewData["Title"] = "FinishedUpdateDetail";
	Layout = "~/Views/Home/Menu.cshtml";
}
<div style="width:1000px;border-color:black;border-style:solid;border-width:2px;margin:10px 20px;">
	<form class="layui-form" action="">
		<h2>基本信息</h2>
		<div class="layui-form-item">
			<div class="layui-inline">
				成品编号:<span id="finishedProductNumbering"></span>
			</div>
			<div class="layui-inline">
				成品名称:<span id="finishedProductName"></span>
			</div>
			<div class="layui-inline">
				规格型号:<span id="finishedProductModel"></span>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				单位:<span id="finishedProductUnit"></span>
			</div>
			<div class="layui-inline">
				库存上限:<span id="finishedProductUpperLimit"></span>
			</div>
			<div class="layui-inline">
				报警天数:提前<span id="finishedProductDays"></span>天报警
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				批次号:<span id="finishedProductBatch"></span>
			</div>
			<div class="layui-inline">
				库存下限:<span id="finishedProductLowerLimit"></span>
			</div>
			<div class="layui-inline">
				状态:<span id="finishedProductState"></span>
			</div>
			<div class="layui-inline">
				备注:<span id="finishedProductRemark"></span>
			</div>
		</div>
	</form>
</div>




<script>
	//文档就绪函数
	$(function () {
		fantian()
	})
	var obj = {
		finishedProductId: 0,
		finishedProductNumbering: "",
		finishedProductName: "",
		finishedProductModel: "",
		finishedProductUnit: "",
		finishedProductUpperLimit: 0,
		finishedProductDays: 0,
		finishedProductBatch: "",
		finishedProductLowerLimit: 0,
		finishedProductState: 0,
		finishedProductRemark: "",
		finishedProductImg: "",
		addName: "",
		addTime: "",
	}
	function fantian() {
		return new Promise(function (resolve, reject) {
			$(document).ready(function () {
				// 获取要编辑的用户ID，可以通过URL参数或者其他方式获取，这里假设通过URL参数获取
				var finishedProductId = localStorage.getItem("finishedProductId");
				console.log(finishedProductId);
				// 如果获取到了用户ID，就去后台获取该用户的详细信息并反填到表单
				if (finishedProductId) {
					$.ajax({
						type: "get",
						url: "/FinishedProduct/FinishedProductAddMondel",
						data: {
							id: finishedProductId,
							token: localStorage.getItem("token")
						},
						success: function (res) {
							console.log(res)
							var rest = JSON.parse(res)
							console.log(rest)
							if (rest.data) {
								var rest = rest.data
								$('#finishedProductId').text(rest.finishedProductId);
								$('#finishedProductName').text(rest.finishedProductName);
								$('#finishedProductNumbering').text(rest.finishedProductNumbering);
								$('#finishedProductModel').text(rest.finishedProductModel);
								$('#finishedProductUnit').text(rest.finishedProductUnit);
								layui.form.render('select')
								$('#finishedProductUpperLimit').text(rest.finishedProductUpperLimit);
								$('#finishedProductDays').text(rest.finishedProductDays);
								$('#finishedProductBatch').text(rest.finishedProductBatch);
								$('#finishedProductLowerLimit').text(rest.finishedProductLowerLimit);
								$('#finishedProductState').text(rest.finishedProductState);
								if (this.finishedProductState == 1) {
								$("#finishedProductState").text("禁用")
							} else {
								$("#finishedProductState").text("启用")
							}
								$('#finishedProductRemark').text(rest.finishedProductRemark);
								$('#finishedProductImg').text(rest.finishedProductImg);
								$('#addName').text(rest.addName);
								$('#addTime').text(rest.addTime);
							}
						}
					})
				}
			});
		});
	}
</script>
